package ru.pb.game.network.threading;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import ru.pb.game.network.engine.auth.packets.AuthServerToGameServerPacket;
import ru.pb.global.network.engine.NioClient;
import ru.pb.global.threading.PriorityThreadFactory;

public class SingleThreadedPacketRunner implements PacketRunner
{

	private ExecutorService _executor = Executors.newSingleThreadExecutor(new PriorityThreadFactory("Normal Packet Pool", DEFAULT_THREAD_PRIORITY));

	@Override
	public void runPacket(AuthServerToGameServerPacket packet)
	{
		if( !_executor.isShutdown())
		{
			_executor.execute(packet);
		}
	}

	@Override
	public void removeContext(NioClient client)
	{}

	@Override
	public void shutdown()
	{
		_executor.shutdown();
	}
}
